package controllers

import (
	"github.com/gin-gonic/gin"
	log "github.com/sirupsen/logrus"
	"net/http"
	"simulationFulu/cores"
	"simulationFulu/models"
)

const FULU_ORDER_CARD_ADD = "fulu.order.card.add"
const FULU_ORDER_INFO_GET = "fulu.order.info.get"

func init() {

}

func Input(c *gin.Context) {
	var req models.InputRequest //通用请求结构
	// 绑定结构 错误处理
	if err := c.ShouldBindJSON(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
		return
	}
	// 验证数据

	// 根据方法处理
	result := &models.OutputResponse{}
	switch req.Method {
	case FULU_ORDER_CARD_ADD:
		log.Info("fulu.order.card.add")
		result.Result = cores.CardOrder(req.BizContent)
	case FULU_ORDER_INFO_GET:
		log.Info("fulu.order.info.get")
		result.Result = cores.CardOrderQuery(req.BizContent)
	}
	result.Code = 0
	result.Message = "接口调用成功"
	//写死
	result.Sign = "1d158f0089b7a091fba0b5df23cd80d5"
	c.JSON(http.StatusOK, result)
}
